package leetcode.code572;

import leetcode.IDebug;
import leetcode.helper.HelpDebug;
import leetcode.helper.tree.TreeArray;
import leetcode.helper.tree.TreeNode;

public abstract class Solution572 implements IDebug {

	public abstract boolean isSubtree(TreeNode root, TreeNode subRoot);

	@Override
	public void debug1() {
//		输入：root = [3,4,5,1,2], subRoot = [4,1,2]
//		输出：true
		String string1 = "[3,4,5,1,2]";
		String string2 = "[4,1,2]";
		boolean expect = true;
		this.debug(string1, string2, expect);
	}

	private void debug(String string1, String string2, boolean expect) {
		new TreeArray();
		TreeNode root = TreeArray.array2tree(HelpDebug.str2array4(string1));
		new TreeArray();
		TreeNode subRoot = TreeArray.array2tree(HelpDebug.str2array4(string2));
		boolean result = this.isSubtree(root, subRoot);
		HelpDebug.compare(expect, result);
	}

	@Override
	public void debug2() {
		String string1 = "[3,4,5,1,2,null,null,null,null,0]";
		String string2 = "[4,1,2]";
		boolean expect = false;
		this.debug(string1, string2, expect);
	}

	@Override
	public void debug3() {
		String string1 = "[1,1]";
		String string2 = "[1]";
		boolean expect = true;
		this.debug(string1, string2, expect);
	}

	@Override
	public void debug4() {
		String string1 = "[3,4,5,1,null,2]";
		String string2 = "[3,1,2]";
		boolean expect = false;
		this.debug(string1, string2, expect);
	}

}
